this is a module to create a datamatrix barcode here are a few webistes used to create this:
In [24]:
part_number = 'replace this with part number' # replace the part number (i.e. ASM-00180-00)
starting_serial_number = 12358 # insert the serial number. DO NOT USE A LEADING ZERO (i.e. 1928 not 01928)
serial_numbers_to_create = 100
# select from the menu above: Cell -> Run All
print(len(str(serial_start))) print(type(serial_start)) print('0'+str(serial_start))
In [25]:
# import all the necessary libraries to make the script work
from pystrich.datamatrix import DataMatrixEncoder
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
In [40]:
output = part_number + str(starting_serial_number) + str(serial_numbers_to_create)
encoder = DataMatrixEncoder(output)
encoder.save("datamatrix_test.png")
# print(encoder.get_ascii())
In [43]:
img = Image.open('datamatrix_test.png')
width, height = img.size
msg = "sample text"
draw = ImageDraw.Draw(img)
w, h = draw.textsize('0'+str(starting_serial_number))
draw.text((((width-w)/2),(height-h)),'0'+str(starting_serial_number))
img.show()
In [ ]: